---
dimensions:
  type:
    primary: implementation
    detail: advanced
  level: advanced
standard_title: Reverse Invocation Node
language: en
title: Node
description: This document describes how plugins can reverse invoke the functionality
  of Chatflow/Workflow application nodes within the Dify platform. It primarily covers
  the invocation methods for two specific nodes, ParameterExtractor and QuestionClassifier.
  The document details the entry points, interface parameters, and example code for
  invoking these two nodes.
---

Reverse invoking a Node means that a plugin can access the capabilities of certain nodes within a Dify Chatflow/Workflow application.

The `ParameterExtractor` and `QuestionClassifier` nodes in `Workflow` encapsulate complex Prompt and code logic, enabling tasks that are difficult to solve with hardcoding through LLMs. Plugins can call these two nodes.

### Calling the Parameter Extractor Node

#### **Entry Point**

```python
    self.session.workflow_node.parameter_extractor
```

#### **Interface**

```python
    def invoke(
        self,
        parameters: list[ParameterConfig],
        model: ModelConfig,
        query: str,
        instruction: str = "",
    ) -> NodeResponse
        pass
```

Here, `parameters` is a list of parameters to be extracted, `model` conforms to the `LLMModelConfig` specification, `query` is the source text for parameter extraction, and `instruction` provides any additional instructions that might be needed for the LLM. For the structure of `NodeResponse`, please refer to this [document](/plugin_dev_en/0411-general-specifications.en.mdx#noderesponse).

#### **Use Case**

To extract a person's name from a conversation, you can refer to the following code:

```python
from collections.abc import Generator
from dify_plugin.entities.tool import ToolInvokeMessage
from dify_plugin import Tool
from dify_plugin.entities.workflow_node import ModelConfig, ParameterConfig, NodeResponse # Assuming NodeResponse is importable

class ParameterExtractorTool(Tool):
    def _invoke(
        self, tool_parameters: dict
    ) -> Generator[ToolInvokeMessage, None, None]:
        response: NodeResponse = self.session.workflow_node.parameter_extractor.invoke(
            parameters=[
                ParameterConfig(
                    name="name",
                    description="name of the person",
                    required=True,
                    type="string",
                )
            ],
            model=ModelConfig(
                provider="langgenius/openai/openai",
                name="gpt-4o-mini",
                completion_params={},
            ),
            query="My name is John Doe",
            instruction="Extract the name of the person",
        )

        # Assuming NodeResponse has an 'outputs' attribute which is a dictionary
        extracted_name = response.outputs.get("name", "Name not found") 
        yield self.create_text_message(extracted_name)
```

### Calling the Question Classifier Node

#### **Entry Point**

```python
    self.session.workflow_node.question_classifier
```

#### **Interface**

```python
    def invoke(
        self,
        classes: list[ClassConfig], # Assuming ClassConfig is defined/imported
        model: ModelConfig,
        query: str,
        instruction: str = "",
    ) -> NodeResponse:
        pass
```

The interface parameters are consistent with `ParameterExtractor`. The final result is stored in `NodeResponse.outputs['class_name']`.

{/*
Contributing Section
DO NOT edit this section!
It will be automatically generated by the script.
*/}

<CardGroup cols="2">
    <Card
        title="Edit this page"
        icon="pen-to-square"
        href="https://github.com/alterxyz/dify-docs-plugin-dev/edit/main/plugin_dev_en/9243-reverse-invocation-node.en.mdx"
    >
        Help improve our documentation by contributing directly
    </Card>
    <Card
        title="Report an issue"
        icon="github"
        href="https://github.com/alterxyz/dify-docs-plugin-dev/issues/new?title=Documentation%20Issue%3A%20reverse-invocation-node&body=%23%23%20Issue%20Description%0A%3C%21--%20Please%20briefly%20describe%20the%20issue%20you%20found%20--%3E%0A%0A%23%23%20Page%20Link%0Ahttps%3A%2F%2Fgithub.com%2Falterxyz%2Fdify-docs-plugin-dev%2Fblob%2Fmain%2Fplugin_dev_en%2F9243-reverse-invocation-node.en.mdx%0A%0A%23%23%20Suggested%20Changes%0A%3C%21--%20If%20you%20have%20specific%20suggestions%20for%20changes%2C%20please%20describe%20them%20here%20--%3E%0A%0A%3C%21--%20Thank%20you%20for%20helping%20improve%20our%20documentation%21%20--%3E"
    >
        Found an error or have suggestions? Let us know
    </Card>
</CardGroup>
